/**
 * Copyright (c) 2012-2014 All Rights Reserved.
 */
package com.easy.framwork.jdbc.handlers;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Map;

/**
 * 
 * @author wy
 * @version v 0.1 2014-1-2 下午9:02:47 wy Exp $
 */
public class ListColumnNameMapHandler extends AbstractListHandler<Map<String, Object>> {

    /**
     * @see com.easy.framwork.jdbc.handlers.AbstractListHandler#handleRow(java.sql.ResultSet,
     *      int)
     */
    @Override
    protected Map<String, Object> handleRow(ResultSet rs, int currentRow) throws SQLException {
        Map<String, Object> result = new CaseInsensitiveHashMap();
        ResultSetMetaData rsmd = rs.getMetaData();
        int cols = rsmd.getColumnCount();

        for (int i = 1; i <= cols; i++) {
            result.put(rsmd.getColumnName(i), rs.getObject(i));
        }

        return result;
    }

}
